package design.prototype;

import java.util.Date;

public class Test {
    public static void main(String[] args) throws CloneNotSupportedException {
        //创建一只克隆羊
        Date date = new Date();
        ClonedSheep c1 = new ClonedSheep("Dolly2",date);
        System.out.println(c1);

        //以上一只克隆羊，进行克隆
        ClonedSheep c2 = (ClonedSheep) c1.clone();
        System.out.println(c2);

        //打印两只羊的hash值，发现不一样，说明是浅克隆（只是两个变量的指向一块内存地址
        System.out.println(c1.hashCode());
        System.out.println(c2.hashCode());

        //将date进行更新之后，再次输出两只羊
        date.setTime(22131231);
        System.out.println(c1);
        System.out.println(c2);
    }
}
